﻿using NewLife.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EMC.VISITOR.Application.Entity
{

    [SugarTable(null, "海康车库表")]
    [BusinessVS]
    public class HKCarPark : EntityBase
    {
        /// <summary>
        /// 停车库唯一标识码
        /// </summary>
        [SugarColumn(ColumnDescription = "停车库唯一标识码", IsNullable = true)]
        public string parkIndexCode { get; set; }
        /// <summary>
        /// 父停车库唯一标识（最大长度64）
        /// </summary>
        [SugarColumn(ColumnDescription = "父停车库唯一标识", IsNullable = true)]
        public string parentParkIndexCode { get; set; }

        /// <summary>
        /// 停车库名称
        /// </summary>
        [SugarColumn(ColumnDescription = "停车库名称", IsNullable = true)]
        public string parkName { get; set; }

        /// <summary>
        /// 用户获取车道信息（与停车库唯一标识码不同）
        /// </summary>
        [SugarColumn(ColumnDescription = "出入口唯一标识", IsNullable = true)]
        public string entranceIndexCode { get; set; }


        [SugarColumn(ColumnDescription = "车道唯一标识", Length = 3000, IsNullable = true)]
        public string roadwayIndexCode { get; set; }

        [SugarColumn(ColumnDescription = "预约车位剩余数量", IsNullable = true)]
        public int? leftReservePlace { get; set; }

        [SugarColumn(ColumnDescription = "是否双抬杠", IsNullable = true)]
        public bool? isDoubleGan { get; set; }=false;

        [SugarColumn(IsIgnore = true)]
        public List<RoadWay> roadwayList
        {
            get
            {
                if (!roadwayIndexCode.IsNullOrEmpty())
                {
                   return roadwayIndexCode.ToJsonEntity<List<RoadWay>>();
                }
                return new List<RoadWay>();
            }
            set
            {
                if (value != null)
                {
                    roadwayIndexCode = value.ToJson();
                }
            }
        }
        ///// <summary>
        ///// 创建时间
        ///// </summary>
        //[SugarColumn(ColumnDescription = "创建时间", IsNullable = true)]
        //public string createTime { get; set; }

        ///// <summary>
        ///// 更新时间 要求遵守ISO8601标准，如2018-07-26T21:30:08.000+08:00 表示北京时间2017年7月26日21时30分08秒
        ///// </summary>
        //[SugarColumn(ColumnDescription = "更新时间", IsNullable = true)]
        //public string updateTime { get; set; }


        #region 不需要的字段
        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public override DateTime? CreateTime { get; set; }


        /// <summary>
        /// 更新时间
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public override DateTime? UpdateTime { get; set; }
        #endregion
    }

    public class RoadWay
    {
        public string name { get; set; }
        public string value { get; set; }
    }
}
